//index.js
//获取应用实例
const app = getApp()

Page({
    data: {
      navState:0,
      week:[
        {
          id:0,
          xinqi: "Mon",
          isActive: true
        },
      {
        id:1,
        xinqi: "Tue",
        isActive: false 
      },
      {
        id:2,
        xinqi: "Wed",
        isActive: false  
      },
      {
        id:3,
        xinqi: "Thu",
        isActive: false 
      },
      {
        id:4,
        xinqi: "Fri" ,
        isActive: false 
      },
      {
        id:5,
        xinqi: "Sat",
        isActive: false 
      },
      {
        id:6,
        xinqi: "Sun",
        isActive: false 
      }
      ],
      course:{
        Mon:[
          "英语 (1-17 博学楼 C-510)",
          "英语 (1-17 博学楼 C-510)",
          "数据采集与处理 (10-17 博学楼 C-507)",
          "数据采集与处理 (10-17 博学楼 C-507)",
          "",
          "",
          "", 
          "",
          "",
          "",
          "",
          "",
          "",
          // 更多数据...
        ],
        Tue:[
          "软件开发新技术 (9-16 绿 2-508)",
          "软件开发新技术 (9-16 绿 2-508)",
          "软件开发新技术 (9-16 绿 2-508)",
          "软件开发新技术 (9-16 绿 2-508)",
          "工程伦理 (10-17 绿 2-508)",
          "工程伦理 (10-17 绿 2-508)",
          "科技论文写作 (10-13 绿 2-508)", 
          "科技论文写作 (10-13 绿 2-508)",
          "",
          "",
          "",
          "",
          "",
          // 更多数据...
        ],
        Wed:[
          "软件开发新技术 (9-16 绿 2-508)",
          "软件开发新技术 (9-16 绿 2-508)",
          "软件开发新技术 (9-16 绿 2-508)",
          "软件开发新技术 (9-16 绿 2-508)",
          "",
          "",
          "", 
          "",
          "",
          "",
          "",
          "",
          "",
          // 更多数据...
        ],
        Thu:[
          "",
          "",
          "数据采集与处理 (10-17 博学楼 C-510)",
          "数据采集与处理 (10-17 博学楼 C-510)",
          "数据采集与处理 (10-17 博学楼 C-510)",
          "数据采集与处理 (10-17 博学楼 C-510)",
          "数据采集与处理 (10-17 博学楼 C-510)", 
          "数据采集与处理 (10-17 博学楼 C-510)",
          "",
          "",
          "",
          "",
          "",
          // 更多数据...
        ],
        Fri:[
          "数值分析 (10-17 绿 2-202)",
          "数值分析 (10-17 绿 2-202)",
          "",
          "",
          "自然辨证法 (10-18 绿 2-220)",
          "自然辨证法 (10-18 绿 2-220)",
          "", 
          "",
          "",
          "",
          "",
          "",
          "",
          // 更多数据...
        ],
        Sat:[
          "",
          "",
          "",
          "",
          "中特 (1-18 绿 2-202)",
          "中特 (1-18 绿 2-202)",
          "", 
          "",
          "",
          "",
          "",
          "",
          "",
          // 更多数据...
        ],
        Sun:[
          "",
          "",
          "",
          "",
          "",
          "",
          "", 
          "",
          "",
          "",
          "",
          "",
          "",
          // 更多数据...
        ],
      },
      currentCourse:[
        "英语 (1-17 博学楼 C-510)",
        "英语 (1-17 博学楼 C-510)",
        "数据采集与处理 (10-17 博学楼 C-507)",
        "数据采集与处理 (10-17 博学楼 C-507)",
        "",
        "",
        "", 
        "",
        "",
        "",
        "",
        "",
        "",
        // 更多数据...
      ]
    },
  
  changeTab: function (params) {
    // 设置
    var that = this;
    let {week} = this.data;
    //箭头函数左边是传入的对象右边是对该对象的操作
    console.log(week)
    week.forEach((item,i) => i===params?item.isActive=true:item.isActive=false);

    //将修改后的数组赋值回去
    that.setData({
      week
    })
  },

  scroll_tap: function (e) {
    console.log(e.currentTarget.dataset)
    //获取当前被点击的标签的 id
    //被点击的 item 的序号：e.currentTarget.dataset.index + 1
    var that = this;
    const {index} = e.currentTarget.dataset;
    //获取data中的数组
    let {week} = this.data;
    //箭头函数左边是传入的对象右边是对该对象的操作
    console.log(week)
    week.forEach((item,i) => i===index?item.isActive=true:item.isActive=false);

    //将修改后的数组赋值回去
    that.setData({
      week
    })

    console.log(week)
  },
  tabSelect(e) {
    this.setData({
      TabCur: e.currentTarget.dataset.id,
      scrollLeft: (e.currentTarget.dataset.id-1)*60
    })
  },
  bindchange:function (e) {
    // 获取当前页面的序号
    console.log(e.currentTarget.detail)
    //console.log(this.data.course.Mon)
    var that = this;
    let key = e.detail.current
    console.log(key)
    this.setData({
      navState:key
    })
  },
  navSwitch: function (e) {
    console.log(e.currentTarget.dataset.index)
    this.setData({
      navState:e.currentTarget.dataset.index
    })
  },
  onShow: function (e) {
    console.log("hello")
    var date = new Date();
    console.log(date.getDay());
    if (date.getDay() === 0)
    {
      this.setData({
        navState:6
      })
    }else{
      this.setData({
        navState:date.getDay()-1
      })
    }
  },
})